/////////////
// z-indexes
$container_z: 1;
$main_z: 1;
$page_menu_z: 1;
$page_menu_viewport_z: 1;
$action_size: 16px;
@mixin popup() {
  .esri-popup {
    pointer-events: none;
  }
  .esri-popup--feature-updated .esri-popup__header-title,
  .esri-popup--feature-updated .esri-popup__content {
    opacity: 1;
    animation: esri-fade-in 375ms ease-out;
  }
  .esri-popup--shadow {
    @include boxShadow("0 1px 4px rgba(0, 0, 0, .8)");
  }
  .esri-popup__button {
    padding: $cap_spacing floor($side_spacing/2);
    line-height: $line_height;
    cursor: pointer;
    user-select: none;
    color: $button_text_color;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
  }
  .esri-popup__button:hover {
    color: $button_text_hover_color;
  }
  .esri-popup [role="button"] [class*="esri-icon"],
  .esri-popup__feature-buttons [class*="esri-icon"] {
    width: $popup_icon_text_size;
    height: $popup_icon_text_size;
    text-align: center;
    vertical-align: middle;
    font-size: $popup_icon_text_size;
  }
  .esri-popup__position-container {
    position: absolute;
    z-index: $container_z;
    display: flex;
  }
  .esri-popup--aligned-top-center {
    transform-origin: 50% 100%;
  }
  .esri-popup--aligned-bottom-center {
    transform-origin: 50% -5%;
  }
  .esri-popup--aligned-top-left,
  .esri-popup--aligned-bottom-left {
    transform-origin: 100% 50%;
  }
  .esri-popup--aligned-top-right,
  .esri-popup--aligned-bottom-right {
    transform-origin: -5% 50%;
  }
  .esri-popup--aligned-top-center,
  .esri-popup--aligned-top-left,
  .esri-popup--aligned-top-right {
    animation: popup-intro-animation-down 200ms ease-in-out;
  }
  .esri-popup--aligned-bottom-center,
  .esri-popup--aligned-bottom-left,
  .esri-popup--aligned-bottom-right {
    animation: popup-intro-animation-up 200ms ease-in-out;
  }
  .esri-popup__main-container {
    outline: none;
    pointer-events: auto;
    position: relative;
    z-index: $main_z;
    width: 340px;
    max-height: 300px;
    background-color: $background_color;
    display: flex;
    flex-flow: column nowrap;
  }
  .esri-popup__header {
    position: relative;
    font-size: $body_text_size;
    align-items: flex-start;
    justify-content: space-between;
    display: flex;
    flex: 0 0 auto;
  }
  .esri-popup__header-buttons {
    padding: 0 floor($side_spacing/2);
    margin: 0 0 0 auto; // `auto` here helps place each node at either end of the container node
    display: flex;
  }
  .esri-popup__header-title,
  h1.esri-popup__header-title {
    // More specific to overwrite .esri-widget H1 selector
    font-size: $title_text_size;
    font-weight: $text_weight_title;
    padding: $cap_spacing $side_spacing;
    margin: 0 auto 0 0;
    display: block;
    flex: 1;
    opacity: 0;
    word-break: break-word;
  }
  .esri-popup__header-title--button {
    cursor: pointer;
  }
  .esri-popup__content {
    display: flex;
    flex-flow: column nowrap;
    flex: 1 1 auto;
    font-size: $body_text_size;
    font-weight: $text_weight_normal;
    margin: 0 $side_spacing $cap_spacing;
    overflow: auto;
    overflow-x: hidden;
  }
  .esri-popup--feature-menu-open .esri-popup__header,
  .esri-popup--feature-menu-open .esri-popup__content {
    flex: 0 1 0px;
    overflow: hidden;
    opacity: 0;
  }
  .esri-popup__content h1,
  .esri-popup__content h2,
  .esri-popup__content h3,
  .esri-popup__content h4,
  .esri-popup__content h5,
  .esri-popup__content h6 {
    margin: 0.5em 0 0.5em 0;
    letter-spacing: 0;
    font-weight: $text_weight_header;
    line-height: 1.3em;
  }
  .esri-popup__content p {
    font-size: $body_text_size;
    line-height: 1.3em;
    margin: 0 0 1.2em;
  }
  .esri-popup__content a {
    color: $anchor_color;
    text-decoration: underline;
  }
  .esri-popup__content a:hover {
    color: $anchor_hover_color;
  }
  .esri-popup__pagination-page-text {
    white-space: nowrap;
  }
  .esri-popup__feature-buttons,
  .esri-popup__feature-buttons [role="button"] {
    font-weight: $text_weight_normal;
    font-size: $text_size_small;
    position: relative;
    display: flex;
    justify-content: flex-start;
    flex: 0 0 auto;
  }
  .esri-popup__feature-buttons .esri-popup__actions {
    padding: 0 floor($side_spacing/4);
    display: flex;
    flex: 2;
    align-items: center;
  }
  .esri-popup__feature-buttons .esri-popup__action {
    max-width: 50%;
  }
  [class*="esri-popup--is-docked-top-"] .esri-popup__feature-buttons,
  [class*="esri-popup--aligned-bottom-"] .esri-popup__feature-buttons {
    border-bottom: solid 1px $border_color;
  }
  [class*="esri-popup--is-docked-bottom-"] .esri-popup__content ~ .esri-popup__feature-buttons,
  [class*="esri-popup--aligned-top-"] .esri-popup__content ~ .esri-popup__feature-buttons {
    // esri-popup__feature-buttons are on the bottom of the popup
    margin-top: -$cap_spacing;
  }
  .esri-popup__navigation {
    padding: 0 floor($side_spacing/2);
    align-items: center;
    display: flex;
    justify-content: flex-end;
    flex: 1;
  }
  .esri-popup__navigation-buttons {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  } ///////////////
  // FEATURE MENU
  .esri-popup__feature-menu {
    left: 0;
    font-size: $body_text_size;
    font-weight: $text_weight_normal;
    position: absolute;
    width: 100%;
    background-color: $page_menu_background_color;
    color: $text_inverse_color;
    z-index: $page_menu_z;
    max-height: 0;
    opacity: 0;
    height: 0;
    overflow: hidden;
    @include boxShadow(0 1px 6px rgba(0, 0, 0, 0.33));
  }
  .esri-popup__feature-menu:after {
    right: $side_spacing;
    position: absolute;
    width: 12px;
    height: 12px;
    transform: rotate(45deg);
    content: "";
    display: block;
    background-color: inherit;
    pointer-events: none;
  }
  [class*="esri-popup--is-docked-bottom-"].esri-popup--is-docked .esri-popup__feature-menu,
  [class*="esri-popup--aligned-top-"] .esri-popup__feature-menu {
    bottom: 36px;
    top: auto;
  }
  [class*="esri-popup--is-docked-bottom-"].esri-popup--is-docked .esri-popup__feature-menu:after,
  [class*="esri-popup--aligned-top-"] .esri-popup__feature-menu:after {
    bottom: -5px;
    top: auto;
  }
  [class*="esri-popup--is-docked-top-"].esri-popup--is-docked .esri-popup__feature-menu,
  [class*="esri-popup--aligned-bottom-"] .esri-popup__feature-menu {
    bottom: auto;
    top: 36px;
  }
  [class*="esri-popup--is-docked-top-"].esri-popup--is-docked .esri-popup__feature-menu:after,
  [class*="esri-popup--aligned-bottom-"] .esri-popup__feature-menu:after {
    bottom: auto;
    top: -5px;
    background-color: inherit;
  }

  .esri-popup__feature-menu-list {
    padding: 0;
    margin: 0;
    counter-reset: section;
  }
  .esri-popup__feature-menu-item {
    list-style-type: none;
    border: solid 1px $border_color;
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    transition: background-color 125ms ease-in-out;
  }
  .esri-popup__feature-menu-item:hover {
    cursor: pointer;
    background-color: $background_active_reverse_color;
  }
  .esri-popup__feature-menu-item:focus {
    outline: none;
    border: solid 1px rgba($background_color, 0.5);
  }
  .esri-popup__feature-menu-item::before {
    counter-increment: section;
    content: counter(section);
    display: flex;
    justify-content: center;
    flex: 0 0 8%;
    text-align: center;
  }
  .esri-popup__feature-menu-item--selected,
  .esri-popup__feature-menu-item--selected:hover {
    background-color: $background_active_reverse_color;
    color: $active_text_reverse_color;
  }
  .esri-popup__feature-menu-item .esri-icon-check-mark {
    padding: 0 .5rem;
  }
  .esri-popup__feature-menu-title {
    display: flex;
    flex: 1 0 82%;
    min-height: 1em;
    margin: 0;
    padding: .8em 4%;
    border-left: solid 1px rgba(0, 0, 0, 0.25);
  }
  .esri-popup__feature-menu-viewport {
    max-height: 0px;
    opacity: 0;
    overflow: auto;
    position: relative;
    z-index: $page_menu_viewport_z;
    transition: max-height 250ms ease-out 62ms;
  }
  .esri-popup__feature-menu .esri-popup__feature-menu-header {
    // More specific to override some default H2 styles.
    background-color: transparent;
    border-bottom: solid 1px $border_color;
    padding: 0;
    margin: 0;
    font-weight: $text_weight_normal;
    font-size: $text_size;
    line-height: 1.2em;
    overflow: hidden;
    position: relative;
    opacity: 0;
    transition: opacity 250ms ease-in-out 200ms;
  }
  .esri-popup--feature-menu-open .esri-popup__feature-menu {
    height: auto;
    opacity: 1;
    animation: esri-fade-in 125ms ease-out;
    max-height: none;
    overflow: visible;
  }
  .esri-popup--feature-menu-open .esri-popup__feature-menu-header {
    padding: $cap_spacing $side_spacing;
    max-height: none;
    display: block;
    opacity: 1;
    margin: 0;
  }
  .esri-popup--feature-menu-open .esri-popup__feature-menu-viewport {
    max-height: 175px;
    opacity: 1;
  }
  .esri-popup__loading-container {
    margin: 0 floor($side_spacing/2);
    text-align: center;
    user-select: none;
  }
  .esri-popup__action-image {
    width: $action_size;
    height: $action_size;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: 50% 50%;
    flex: 1 0 $action_size;
  }
  .esri-popup__action-text {
    margin: 0 floor($side_spacing/3);
    overflow:hidden;
    text-overflow: ellipsis;
  } ///////////////
  // POINTER
  $half_pointer_width: ($popup_pointer_width / 2)+px;
  $half_pointer_height: ($popup_pointer_height / 2)+px;
  $neg_half_pointer_width: (-($popup_pointer_width / 2))+px;
  $neg_half_pointer_height: (-($popup_pointer_height / 2))+px;
  .esri-popup__pointer {
    position: absolute;
    width: 0;
    height: 0;
  }
  .esri-popup__pointer-direction {
    background-color: $background_color;
    @include pointerStyle($popup_pointer_width, $popup_pointer_height);
  }
  .esri-popup--aligned-top-center .esri-popup__pointer {
    top: 100%;
    left: 50%;
    margin: 0 0 0 $neg_half_pointer_width;
  }
  .esri-popup--aligned-bottom-center .esri-popup__pointer {
    bottom: 100%;
    left: 50%;
    margin: 0 0 0 $neg_half_pointer_width;
  }
  .esri-popup--aligned-top-left .esri-popup__pointer {
    bottom: $half_pointer_height;
    right: $half_pointer_width;
    transform: rotate(-45deg);
  }
  .esri-popup--aligned-bottom-left .esri-popup__pointer {
    top: $half_pointer_height;
    right: $half_pointer_width;
    transform: rotate(45deg);
  }
  .esri-popup--aligned-top-right .esri-popup__pointer {
    bottom: $half_pointer_height;
    left: $half_pointer_width;
    transform: rotate(45deg);
  }
  .esri-popup--aligned-bottom-right .esri-popup__pointer {
    top: $half_pointer_height;
    left: $half_pointer_width;
    transform: rotate(-45deg);
  }
  .esri-popup--aligned-top-center .esri-popup__pointer-direction,
  .esri-popup--aligned-bottom-center .esri-popup__pointer-direction {
    transform: scale($popup_pointer_scale_x, $popup_pointer_scale_y) rotate(45deg);
  }
  .esri-popup--aligned-top-left .esri-popup__pointer-direction,
  .esri-popup--aligned-bottom-left .esri-popup__pointer-direction,
  .esri-popup--aligned-top-right .esri-popup__pointer-direction,
  .esri-popup--aligned-bottom-right .esri-popup__pointer-direction {
    top: $neg_half_pointer_height;
    left: $neg_half_pointer_width;
    transform: scale($popup_pointer_corner_scale_x, $popup_pointer_corner_scale_y) rotate(45deg);
  }
  .esri-popup--aligned-top-center .esri-popup__pointer-direction {
    top: $neg_half_pointer_height;
    left: 0;
  }
  .esri-popup--aligned-bottom-center .esri-popup__pointer-direction {
    bottom: $neg_half_pointer_height;
    left: 0;
  } ///////////////////
  //  SCREEN SIZES
  //  WIDTHS
  .esri-view-width-xlarge {
    @include popupWidth_BasedOnViewSize(460);
  }
  .esri-view-width-large {
    @include popupWidth_BasedOnViewSize(400);
  }
  .esri-view-width-less-than-large .esri-popup__action-text {
    display: none;
  }
  .esri-view-width-medium {
    @include popupWidth_BasedOnViewSize(340);
  }
  .esri-view-width-less-than-small {
    @include popupWidth_BasedOnViewSize(280);
  }
  .esri-view-width-xsmall .esri-popup__button[class*="esri-popup__navigation-"],
  .esri-view-width-xsmall .esri-popup__pagination-page-text {
    display: none;
  }
  .esri-view-width-xsmall .esri-popup--is-docked-bottom-center {
    margin-bottom: $docked_margin+1;
  }
  .esri-view-width-xsmall .esri-popup--is-docked-top-center,
  .esri-view-width-xsmall .esri-popup--is-docked-bottom-center {
    width: auto;
    margin: 0;
  }
  .esri-view-width-xsmall .esri-popup--is-docked-top-center .esri-popup__main-container,
  .esri-view-width-xsmall .esri-popup--is-docked-bottom-center .esri-popup__main-container {
    width: 100%; // Full width, auto-docked
    max-height: 35%;
    position: absolute;
    bottom: 0;
    @include boxShadow("none"); // Avoids width animation when auto-docking on resize
  } //  HEIGHTS
  .esri-view-height-xlarge {
    @include popupHeight_BasedOnViewSize(320);
  }
  .esri-view-height-large {
    @include popupHeight_BasedOnViewSize(280);
  }
  .esri-view-height-less-than-medium {
    @include popupHeight_BasedOnViewSize(200); // Default height
  } //  SCREEN SIZES
  ///////////////////
  ///////////////////
  // DOCKED
  .esri-popup--is-docked {
    left: 0;
    bottom: 0;
    right: 0;
    top: 0;
    margin: $docked_margin $docked_margin $docked_margin*2 $docked_margin;
    animation: esri-docking-animation 250ms ease-out;
  }
  .esri-popup--is-docked .esri-popup__header {
    padding-top: 2px;
  }
  .esri-popup--is-docked-top-left,
  .esri-popup--is-docked-top-center,
  .esri-popup--is-docked-top-right {
    align-items: flex-start;
  }
  .esri-popup--is-docked-bottom-left,
  .esri-popup--is-docked-bottom-center,
  .esri-popup--is-docked-bottom-right {
    align-items: flex-end;
  }
  .esri-popup--is-docked-top-left,
  .esri-popup--is-docked-bottom-left {
    justify-content: flex-start;
  }
  .esri-popup--is-docked-top-center,
  .esri-popup--is-docked-bottom-center {
    justify-content: center;
  }
  .esri-popup--is-docked-top-right,
  .esri-popup--is-docked-bottom-right {
    justify-content: flex-end;
  }
  .esri-popup--is-docked-top-left .esri-popup__main-container,
  .esri-popup--is-docked-top-right .esri-popup__main-container,
  .esri-popup--is-docked-bottom-left .esri-popup__main-container,
  .esri-popup--is-docked-bottom-right .esri-popup__main-container {
    max-height: 80%;
  }
  [class*="esri-popup--is-docked-bottom-"] .esri-popup__main-container {
    position: absolute;
    bottom: 0;
  }
  //  DOCKED
  ////////////////////
  ////////////////////
  //  RTL
  html[dir="rtl"] {
    .esri-widget .esri-popup__header-title,
    .esri-popup__header-title {
      margin: 0 0 0 auto;
    }
    .esri-popup__header-buttons {
      margin: 0 auto 0 0;
    }
    .esri-popup__feature-menu-title {
      border-left: none;
      border-right: solid 1px rgba(0, 0, 0, 0.25);
    }
    .esri-popup__feature-menu:after {
      right: auto;
      left: $side_spacing;
    }
    .esri-popup__navigation {
      margin: 0 auto 0 0;
    }
    .esri-popup__actions {
      margin: 0 0 0 auto;
    }
    .esri-popup--is-docked .esri-popup__loading-container {
      order: 0;
    }
    .esri-popup--is-docked-top-left,
    .esri-popup--is-docked-bottom-left {
      justify-content: flex-end;
    }
    .esri-popup--is-docked-top-right,
    .esri-popup--is-docked-bottom-right {
      justify-content: flex-start;
    }
  } //  RTL
  ////////////////////
}

@keyframes esri-docking-animation {
  0% {
    opacity: 0;
  }
  25% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes popup-intro-animation-down {
  0% {
    transform: translate(0, -5px);
    opacity: 0;
  }
  100% {
    transform: translate(0, 0);
    opacity: 1;
  }
}

@keyframes popup-intro-animation-up {
  0% {
    transform: translate(0, 5px);
    opacity: 0;
  }
  100% {
    transform: translate(0, 0);
    opacity: 1;
  }
}

@if $include_Popup==true {
  @include popup();
}

